package com.rentong.wx.sys.controller;

import com.rentong.basic.ResultInfo;
import com.rentong.wx.sys.dao.SysCityDao;
import com.rentong.wx.sys.domain.SysCityEntity;
import com.rentong.wx.sys.service.SysCityService;
import com.rentong.wx.utils.TencentMapReverseGeocoding;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 省市区数据表
 *
 * @author zhangle
 * @email 459343178@qq.com
 * @date 2024-12-24 14:42:30
 */
@RestController
public class SysCityController {

    @Autowired
    private SysCityService sysCityService;

    @Autowired
    private SysCityDao sysCityDao;


    /**
     *  3、首页，根据经纬度，获取所在城市
     *
     * **/
    @RequestMapping("/wx/sys/getLocationByLonAndLat")
    public ResultInfo getLocationByLonAndLat(String longitude, String latitude) {
        String cityName = TencentMapReverseGeocoding.getCity(longitude, latitude);
        System.out.println(cityName);
        SysCityEntity cityEntity = sysCityDao.getCityByName(cityName);

        return ResultInfo.success(cityEntity);
    }

    /**
     *  4、首页，加载省市的下拉框
     *
     * **/
    @RequestMapping("/wx/sys/getProvinceAndCityLabel")
    public ResultInfo getProvinceAndCityLabel(Long pid) {
        return ResultInfo.success(sysCityService.getProvinceAndCityLabel(pid));
    }

    /**
     *  215、查询热门城市
     *
     * **/
    @RequestMapping("/wx/sys/getHotCity")
    public ResultInfo getHotCity() {
        return ResultInfo.success(sysCityService.getHotCity());
    }

    /**
     *  216、查询所有城市
     *
     * **/
    @RequestMapping("/wx/sys/getAllCity")
    public ResultInfo getAllCity() {
        return ResultInfo.success(sysCityService.getAllCity());
    }




}
